package com.sptpc.demo.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;
import org.joda.money.Money;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


@Entity
@Table(name = "t_drink")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Drink {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer id; // 饮品编号

    @Column(name = "name")
    @NotBlank(message = "饮品名字不能为空")
    public String name; // 饮品名称



    @NotNull
    @Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyAmount",
            parameters = {@org.hibernate.annotations.Parameter(name = "currencyCode", value = "CNY")})
    @NotNull
    public Money price; // 饮品价格

    @ManyToOne
    @JsonIgnoreProperties(value = {"hibernateLazyInitializer"})
    public Category category;

//    @DateTimeFormat(pattern = "yyyy-MM-dd")
//    public LocalDate enrollDate; // 上架时间
}
